int incomingByte = 0;   // for incoming serial data
int lockStatement = 0; // car's lock statement
int led1 = 9;
int led2 = 10;
int doorSensor = 11;
int doorCheck = 0;
int doorState;

void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(doorSensor, INPUT);
  Serial.begin(9600);
}

void loop() {
  doorCheck = digitalRead(doorSensor); 
  if(doorCheck == 1){
    if(Serial.available() > 0) {
      incomingByte = Serial.read(); // read the incoming byte:
      switch (doorState){
        case 0 : {
          digitalWrite(led1, LOW);
          if(incomingByte == 'L'){
            digitalWrite(led2, HIGH);
            delay(1000);
            digitalWrite(led2, LOW);
            doorState = 1;
          }
        }
        case 1 : { //door LOCK
          digitalWrite(led1, HIGH);
          if(incomingByte == 'U'){
            digitalWrite(led2, HIGH);
            delay(1000);
            digitalWrite(led2, LOW);
            delay(1000);
            digitalWrite(led2, HIGH);
            delay(1000);
            digitalWrite(led2, LOW);
          }
        }
      }
    }
  }
}
